package com.songqintuan.common.dal.database.routing;

import java.sql.SQLException;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

import com.songqintuan.common.dal.database.DataSourceContextHolder;

public class RoutingDataSource extends AbstractRoutingDataSource {

	@Override
	protected Object determineCurrentLookupKey() {
		if (DataSourceContextHolder.getDataSourceType() == "FMS"
				|| DataSourceContextHolder.getDataSourceType() == null) {
			return DataSourceContextHolder.getStation();
		} else {
			return DataSourceContextHolder.getDataSourceType();
		}
	}

	public <T> T unwrap(Class<T> iface) throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean isWrapperFor(Class<?> iface) throws SQLException {
		// TODO Auto-generated method stub
		return false;
	}
}
